﻿using System;
using System.Data;
using System.Configuration;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;

/// <summary>
/// Summary description for Product
/// </summary>
public class Product
{
    private int _pdID;
    private int _catID;
    private String _pdName;
    private String _pdDescription;
    private int _pdQuantity;
    private decimal _pdPrice;
    private String _pdImage;
    private DateTime _pdDatetime;
    public int PdID
    {
        get { return _pdID; }
        set { _pdID = value; }
    }  

    public int CatID
    {
        get { return _catID; }
        set { _catID = value; }
    }
    
    public String PdName
    {
        get { return _pdName; }
        set { _pdName = value; }
    }
    
    public String PdDescription
    {
        get { return _pdDescription; }
        set { _pdDescription = value; }
    }
   
    public int PdQuantity
    {
        get { return _pdQuantity; }
        set { _pdQuantity = value; }
    }

    public decimal PdPrice
    {
        get { return _pdPrice; }
        set { _pdPrice = value; }
    }
    
    public String PdImage
    {
        get { return _pdImage; }
        set { _pdImage = value; }
    }
   
    public DateTime PdDatetime
    {
        get { return _pdDatetime; }
        set { _pdDatetime = value; }
    }

    public Product()
    { }

	public Product(int _pdId)
	{
        this._pdID = _pdId;

        ProductBus ProductBus = new ProductBus();
        DataTable dt = new DataTable();
        //truyen vao id lay du lieu gan cho datatable
        dt = ProductBus.GetProductByID(_pdID);
        //neu co ban ghi thi thuc hien thao tac
        if(dt.Rows.Count>0)
        {
            //lay du lieu gan cho bien
            this._pdID = int.Parse(dt.Rows[0]["pd_id"].ToString());
            this._catID = int.Parse(dt.Rows[0]["cat_id"].ToString());
            this._pdName = dt.Rows[0]["pd_name"].ToString();
            this._pdDescription = dt.Rows[0]["pd_description"].ToString();
            this._pdQuantity = int.Parse(dt.Rows[0]["pd_quantity"].ToString());
            this._pdPrice = decimal.Parse(dt.Rows[0]["pd_price"].ToString());
            this._pdImage = dt.Rows[0]["pd_image"].ToString();
            this._pdDatetime = DateTime.Parse(dt.Rows[0]["pd_date"].ToString());

        }
        
	}
}
